<%@ page import="schoolsource.sql.SchoolDBSQL" %>
<%@ page import="schoolsource.model.*" %>
<%@ page import="schoolsource.gui.*" %>
<%@ page import="schoolsource.security.SecurityToken" %>
<% SecurityToken st = (SecurityToken) request.getAttribute(FormFields.SESSION);
   String requestObject = (String) st.getValue(FormFields.TOKEN);
   boolean parent = (st.getValue(FormFields.ISPARENT) != null);
   String name = (String) st.getValue(SchoolDBSQL.USRFNAME) + " " + (String) st.getValue(SchoolDBSQL.USRLNAME);
   ClassContainer classC[] = (ClassContainer[]) st.getValue("classContainer");
   ContactContainer commC[] = (ContactContainer[]) st.getValue("communicationContainer");
   UserContainer studentContainer = (UserContainer) st.getValue("studentContainer");
   UserContainer studentClassTeacher[] = (UserContainer[]) st.getValue("studentClassTeacher");
   UserContainer studentCommTeacher[] = (UserContainer[]) st.getValue("teacherWhoSentMail");
   int classnum = (new Integer((String) st.getValue(FormFields.CLASSNUM))).intValue();
   HomeworkContainer studentHomework[] = (HomeworkContainer[]) st.getValue("homeworkContainer"); 
   GradeContainer studentGrade[] = (GradeContainer[]) st.getValue("studentGrade");
   UserContainer child = (UserContainer) st.getValue("childContainer");
   String displayMessage = (String) st.getValue("displayMessage"); 
   st.putValue("displayMessage", "");
   String loginType = (String) request.getAttribute(FormFields.USRTYPE); 
   String schoolName = (String) request.getAttribute(FormFields.SCHOOLNAME);
   SchoolContainer sc = SchoolContainer.getSchoolContainer(st.getValue(FormFields.SCHOOLNAME).toString());

   String activeMenuBar = sc.getSchoolActiveMenuBarColor().toString();
   String inactiveMenuBar = sc.getSchoolInactiveMenuBarColor().toString();
   String activeLink = sc.getSchoolActiveLinkColor().toString();
   String inactiveLink = sc.getSchoolInactiveLinkColor().toString();
   String headingColor = sc.getSchoolMenuHeadingColor().toString();
   String headingFont = sc.getSchoolHeadingFont().toString();
   String backgroundColor = sc.getSchoolMenuBackgroundColor().toString();
   String schoolLogo = sc.getSchoolLogo().toString();
   String schoolLogoWidth = sc.getSchoolLogoWidth().toString();

%>

<HTML>
  <HEAD>
    <SCRIPT>

      var state = 0;
      var selecteditem = -1;
       
      function getProperties(x) {
        var outtext = "";
        var counter = 0;
        for (var i in x) {
          outtext = outtext + "*** " + i + ": " + x[i] + "\n";
        }
        if (outtext != "") {
          confirm(outtext);
        }
      }

      function switchGif(x) {
        x.src="../pics/openenvelope.gif";
      }

      function notify(x) {
          alert(x);
      }
      
      function refresh() {
          top.frames.mainframe.submitPage(top.frames.mainframe.document,"Refresh", -1);
      }

      function init() {
        top.frames.mainframe.initializeViewFrame(top.frames.viewframe, "View Area");
        top.frames.mainframe.initializeMenuFrame(top.frames.menuframe);
        top.frames.mainframe.updateMenu();

        if ("<%= displayMessage %>" != "null" && "<%= displayMessage %>" != "") {
          top.frames.mainframe.notify("<%= displayMessage %>");
          top.frames.mainframe.refresh();
        }
      }

      function initializeViewFrame(w, initialText) {
        var d = w.document;
        d.write("    <HTML><HEAD></HEAD>\n");
        d.write("    <BODY>\n");
        
        d.write("      <center><B>" + initialText + "<B><br><br></center>");
        d.write("      <FORM NAME=\"initialCIFrame\" METHOD=\"POST\">\n");
        d.write("        <INPUT TYPE=\"HIDDEN\" NAME=\"<%= FormFields.CURRENT %>\" VALUE=\"<%= FormFields.SUBFRAME %>\">\n");
        d.write("        <INPUT TYPE=\"HIDDEN\" NAME=\"<%= FormFields.TOKEN %>\" VALUE=\"<%= requestObject%>\">\n");
        d.write("        <INPUT TYPE=\"HIDDEN\" NAME=\"<%= FormFields.PARAMETER %>\" VALUE=\"\">\n");
        d.write("        <INPUT TYPE=\"HIDDEN\" NAME=\"<%= FormFields.LINKCLICKED %>\" VALUE=\"\">\n");
        d.write("        <INPUT TYPE=\"HIDDEN\" NAME=\"<%= FormFields.CLASSNUM %>\" VALUE=\"<%= classnum %>\">");
        d.write("      </FORM>\n");
        d.write("<p>&nbsp\n");
        d.write("<p>&nbsp\n");
        d.write("<p>&nbsp\n");
        d.write("    </BODY></HTML>\n");
        d.close();
      }

      function initializePrintFrame(w, originalText) {
        var d = w.document;
//        originalText = originalText.replace(/<noPrint>(^<\/noPrint>|.|\n)*<\/noPrint>/gim, "");
//        originalText = originalText.replace(/<input .*hidden[^>]*>/gim, "");
//        originalText = originalText.replace(/<input .*type\=submit[^>]*>/gim, "");
//        originalText = originalText.replace(/<input .*type\=button[^>]*>/gim, "");
//        originalText = originalText.replace(/<input .*type\=radio[^>]*>/gim, "");
//        originalText = originalText.replace(/<textarea .*>(.*)<\/textarea>/gim, "$1");
//        originalText = originalText.replace(/<input [^>]*value ?\= ?"([^"]*)"[^>]*>/gim, "$1");
//        originalText = originalText.replace(/<input [^>]*value ?\= ?([^ ]*)[^>]*>/gim, "$1");
//        originalText = originalText.replace(/<input [^>]*>/gim, "");
        d.write("    <HTML><HEAD></HEAD>\n");
        d.write(originalText);
        d.write("</HTML>\n");
        d.close();
      }

      function initializeMenuFrame(w) {
        var d = w.document;
        d.write("    <HTML><HEAD>\n");
        d.write(" </HEAD><BODY style=\"COLOR: <%= headingColor %>; background-color:<%=backgroundColor%>; position:relative; left:0;\">");
        
        d.write("<DIV><IMG src=\"../pics/<%= schoolLogo %>\" <%= ("".equals(schoolLogoWidth)) ? "width='80%'" : "width=" + schoolLogoWidth + ";" %> style=\"border:0;white-space:nowrap;\"><br><br>");
        d.write("      <FONT SIZE=\"4\" COLOR=\"<%= headingColor %>\"><B><%= studentContainer.getFirstName().toString() + " " + studentContainer.getLastName().toString()%></B></FONT><br>");
        d.write("      <FONT COLOR=\"<%= headingColor %>\">ID: <%= studentContainer.getSchoolID().toString() %></FONT><br>");
        <%
          if (parent) out.println("d.write(\"<FONT COLOR=\\\"" + headingColor + "\\\" SIZE=\\\"4\\\"><B>Parent of <BR> " + child.getFirstName() + " " + child.getLastName() + "</B><BR></FONT>\");");
        %>
        d.write("      &nbsp;<br></DIV>");

        d.write("      <div name=\"mailmenu\" id=\"mailmenu\" ");
        d.write("           STYLE=\"padding:1;color:<%= headingColor %>;position:relative;\n");
        d.write("           font-family:sans-serif;left:0;\n" );
        d.write("           font-size:12;width:100;white-space:nowrap;\"><B> Messages</B>\n");
        d.write("      <div name=\"newmail\" id=\"newmail\" STYLE=\"padding:1;color:<%= activeLink %>;position:relative;");
        d.write("           height:20;left:10;width:50;white-space:nowrap;\" onClick='top.frames.mainframe.go(this, 2, \"<%= FormFields.MAILLINK %>\", \"-1\");'>");
        d.write("           <a id=\"<%= FormFields.MAILLINK %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= activeLink %>;\" ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\" ");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" ");
        d.write("               onClick='return false;'>New</a></div>\n");
        d.write("      <div name=\"replymail\" id=\"replymail\" STYLE=\"padding:1;color:<%= inactiveLink %>;position:relative;");
        d.write("           height:20;left:10;width:50;white-space:nowrap;\" onClick=\"top.frames.mainframe.go(this, 0, '<%= FormFields.REPLY %>', top.frames.mainframe.getSelected());\">");
        d.write("           <a id=\"<%= FormFields.REPLY %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= inactiveLink %>;\" ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\" ");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" ");
        d.write("               onClick=\"return false;\">Reply</a></div>\n");
        d.write("      <div name=\"deletemail\" id=\"deletemail\" STYLE=\"padding:1;color:<%= inactiveLink %>;position:relative;");
        d.write("           height:20;left:10;width:100;white-space:nowrap;\" onClick='top.frames.mainframe.deleteMail(this, 0, \"<%= FormFields.DELMAIL %>\");'>");
        d.write("           <a id=\"<%= FormFields.DELMAIL %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= inactiveLink %>;\" ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\" ");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" ");
        d.write("               onClick='return false;'>Delete</a></div>\n");
        d.write("      </div><br>");
        d.write("      <div name=\"utilmenu\" id=\"utilmenu\" ");
        d.write("           STYLE=\"padding:1;color:<%= headingColor %>;position:relative;\n");
        d.write("           font-family:sans-serif;left:0;\n" );
        d.write("           font-size:12;width:100;white-space:nowrap;\"><B>Services</B>\n");
        d.write("      <div name=\"progress\" id=\"progress\" STYLE=\"padding:1;color:<%= inactiveLink %>;position:relative;");
        d.write("           height:20;left:10;width:50;white-space:nowrap;\" onClick=\"top.frames.mainframe.go(this, 7, '<%= FormFields.PROGRESSLINK %>', '');\">");
        d.write("           <a id=\"<%= FormFields.PROGRESSLINK %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= activeLink %>;\" ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\" ");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" ");
        d.write("               onClick='return false;'>Progress Report</a></div>\n");
        d.write("      <div name=\"print\" id=\"print\" STYLE=\"padding:1;color:<%= activeLink %>;position:relative;");
        d.write("           height:20;left:10;width:50;white-space:nowrap;\" onClick='top.frames.mainframe.goNewWindow(this, \"<%= FormFields.PRINTLINK %>\", \"-1\");'>");
        d.write("           <a id=\"<%= FormFields.PRINTLINK %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= activeLink %>;\" ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\" ");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" ");
        d.write("               onClick='return false;'>Print</a></div>\n");
        d.write("      <div name=\"refresh\" id=\"refresh\" STYLE=\"padding:1;color:<%= activeLink %>;position:relative;\n");
        d.write("           height:20;left:10;width:100;white-space:nowrap;\" onClick='top.frames.mainframe.submitPage(top.frames.mainframe.document,\"Refresh\", -1);'>\n");
        d.write("           <a id=\"<%= FormFields.REFRESH %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= activeLink %>;\" onMouseOver=\"top.frames.mainframe.makebold(this);\" \n");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" onClick=\"return false;\">\n");
        d.write("               Refresh</a></div>\n");
        d.write("      <div name=\"changepw\" id=\"changepw\" \n");
        d.write("           STYLE=\"padding:1;color:<%= activeLink %>;position:relative;left:10;\n");
        d.write("           height:20;width:50;white-space:nowrap;\" onClick='top.frames.mainframe.go(this, 5, \"<%= FormFields.CHANGEPASSWORD %>\", \"-1\");'>\n");
        d.write("           <a id=\"<%= FormFields.CHANGEPASSWORD %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= activeLink %>;\" onMouseOver=\"top.frames.mainframe.makebold(this);\" onMouseOut=\"this.style.fontWeight='normal';\" onClick='return false;'>Change Password</a></div>\n");
        d.write("      <div name=\"logout\" id=\"logout\" STYLE=\"padding:1;color:<%= activeLink %>;position:relative;left:10;\n");
        d.write("           height:20;width:100;white-space:nowrap;\" onClick='top.frames.mainframe.submitPage(top.frames.mainframe.document,\"<%= FormFields.LOGOUT %>\", -1);'>\n");
        d.write("           <a id=\"<%= FormFields.LOGOUT %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= activeLink %>;\" onMouseOver=\"top.frames.mainframe.makebold(this);\"\n");
        d.write("               onMouseOut='this.style.fontWeight=\"normal\";' onClick='return false;'>\n");
        d.write("               Logout</a></div>\n");
        d.write("      </div>\n");
        d.write("    </BODY></HTML>\n");
        d.close();
      }

    var tableReference = null;
//    var messageTableReference = null;
//    var hqtTableReference = null;
    
    function getTable() {
    
        if (tableReference == null) {
            tableReference = getNodeRecursive(document.body, 'maintable');
        }
        
        return tableReference;
    }
      
//    function getMessageTable() {
//    
//        if (messageTableReference == null) {
//            messageTableReference = getNodeRecursive(document.body, 'messageTable');
//        }
//        
//        return messageTableReference;
//    }
      
//    function getHqtTable() {
//    
//        if (hqtTableReference == null) {
//            hqtTableReference = getNodeRecursive(document.body, 'hqtTable');
//        }
//        
//        return hqtTableReference;
//    }
      
    function setTableWidth() {
        getTable().width = getScreenWidth();
//        getMessageTable().width = getScreenWidth()/2;
//        getHqtTable().width = getScreenWidth()/2;
    }
      
    function getNodeRecursive(parent, id) {
        var result = null;
        var listofnodes = parent.childNodes;
        for (var i = 0;i < listofnodes.length; i++) {
            if (listofnodes.item(i).id == id) {
                return listofnodes.item(i);
            }
            else {
                result = getNodeRecursive(listofnodes[i], id);
                if (result != null) {
                    return result;
                }
            }
        }
        return result;
    }
    
    function getScreenWidth(){
        if (screen.width > 800) {
          return 630;
        }
        else {
          return 630;
        }
      }

      function getNode(listofnodes, nodename) {
        var i = 0;
        for (var i = 0;i < listofnodes.length; i++) {
            if (listofnodes.item(i).id == nodename) {
                return listofnodes[i];
            }
        }
      }

      function blankouterframes() {
          top.frames.viewframe.document.write("<HTML><HEAD></HEAD><BODY></BODY></HTML>");
          top.frames.viewframe.document.close();
          top.frames.menuframe.document.write("<HTML><HEAD></HEAD><BODY></BODY></HTML>");
          top.frames.menuframe.document.close();
      }

      function makebold(k) {
        if (k.style.color == "<%= activeLink %>") {
          k.style.fontWeight = 'bold';
        }
      }

      function go(k, newstate, option, param) {
        var temp = getNode(k.childNodes, option);
        if (temp.style.color != "<%= activeLink %>")  {
          return;
        }
        state = newstate;
        updateMenu();
        if (option != null && param != null) {
          goToNextPage(option, param);
        }
      }

      function goNewWindow(k, option, param) {
        var temp = getNode(k.childNodes, option);
        if (temp.style.color != "<%= activeLink %>")  {
          return;
        }
        if (option != null && param != null) {
    //    getProperties(top.frames.viewframe.document.body.innerHTML);
          var w = window.open('','4087996','width=640,height=480,resizeable=1,status=1,scrollbars=1,menubar=1');    
    
          initializePrintFrame(w, top.frames.viewframe.document.body.innerHTML);
    
        }
      }
      
      function submitPage(d, linkclicked, val) {
          if (linkclicked == "<%= FormFields.LOGOUT %>") {
              blankouterframes();
          }
          d.forms.classinfoform.<%= FormFields.LINKCLICKED %>.value = linkclicked;
          d.forms.classinfoform.<%= FormFields.PARAMETER %>.value = val;
          d.forms.classinfoform.submit();
      }

      function setSelected(k) {
        selectedItem = k;
      }

      function getSelected() {
        return top.frames.mainframe.selectedItem;
      }

      function deleteMail(a, b, c){
        if (getNode(a.childNodes, "<%= FormFields.DELMAIL %>").style.color != "<%= activeLink %>") {
          return;
        }
        if (confirm("Are you sure you want to delete this message?")){
            go(a,b,c,getSelected());
        }
      }

      function goToNextPage(linkclicked, val) {
          var d = top.frames.viewframe.document;
          d.forms[0].<%= FormFields.LINKCLICKED %>.value = linkclicked;
          d.forms[0].<%= FormFields.PARAMETER %>.value = val;
          d.forms[0].submit();
      }
      
      function deletetoken() {
          document.forms[0].submit();
      }

      function loadFrame() {
        // take in values as parameters to use
        // set the values of the form held in top.frames[0].document.forms[0]
        // and then submit it
        //top.frames[0].navigate("temp.html");
      }
      
      function contract(k) {
        var nextSib = k.nextSibling;
        k.style.border = "none";
        while (nextSib != null && nextSib.style != null && nextSib.style.posLeft != 0 && nextSib.style.posLeft < (k.style.posLeft + k.clientWidth)) {
          nextSib.style.clip = "rect(auto " + nextSib.style.clipWidth + "px auto auto)";
          nextSib = nextSib.nextSibling;
        }
        k.style.clip = "rect(auto " + k.style.clipWidth + "px auto auto)";
        k.style.overflow = "hidden";
      }

      function expand(k) {
        var additionalSpace = 5;
        var nextSib = k.nextSibling;
        var newClip = 0;
        k.style.borderWidth = 1;
        k.style.borderColor = "black";
        k.style.borderStyle = "solid";
        k.style.overflow = "visible";
        while (nextSib != null && nextSib.style != null && nextSib.style.posLeft >= k.style.posLeft && nextSib.style.posLeft < (k.style.posLeft + k.clientWidth + additionalSpace)) {
          if ((k.style.posLeft + k.clientWidth + additionalSpace) > (nextSib.style.posLeft + nextSib.clientWidth)) {
            newClip = nextSib.clientWidth;
          }
          else {
            newClip = additionalSpace + k.style.posLeft + k.clientWidth - nextSib.style.posLeft;
          }
          nextSib.style.clip = "rect(auto " + nextSib.style.clipWidth + "px auto " + newClip + "px)";
          nextSib = nextSib.nextSibling;
        }
        k.style.clip = "rect(auto auto auto auto)";
      }

      var highlighteddiv = null;

      function highlight(k,l) {
        var nextdiv = k.parentNode.firstChild;
        if (l == "HW") {
          state = 4;
        }
        else if (l == "Mail") {
          state = 1;
        }
        if (highlighteddiv != null) {
          highlighteddiv.style.background = "#FFFFFF";
        }
        highlighteddiv = k;
        k.style.background = "#EEEEEE";
        updateMenu();
      }


      function updateMenu() {
//         var mainmenu = getNode(top.frames.menuframe.document.body.childNodes, "mainmenu");
         var mailmenu = getNode(top.frames.menuframe.document.body.childNodes, "mailmenu");
         var utilmenu = getNode(top.frames.menuframe.document.body.childNodes, "utilmenu");
         var hwmenu = getNode(top.frames.menuframe.document.body.childNodes, "hwmenu");
         var changepw = getNode(getNode(utilmenu.childNodes, "changepw").childNodes, "<%= FormFields.CHANGEPASSWORD %>");
         var refresh = getNode(getNode(utilmenu.childNodes, "refresh").childNodes, "<%= FormFields.REFRESH %>");
         var logout = getNode(getNode(utilmenu.childNodes, "logout").childNodes, "<%= FormFields.LOGOUT %>");
         var newmail = getNode(getNode(mailmenu.childNodes, "newmail").childNodes, "<%= FormFields.MAILLINK %>");
         var replymail = getNode(getNode(mailmenu.childNodes, "replymail").childNodes, "<%= FormFields.REPLY %>");
         var deletemail = getNode(getNode(mailmenu.childNodes, "deletemail").childNodes, "<%= FormFields.DELMAIL %>");
         var printitem = getNode(getNode(utilmenu.childNodes, "print").childNodes, "<%= FormFields.PRINTLINK %>");
         var progress = getNode(getNode(utilmenu.childNodes, "progress").childNodes, "<%= FormFields.PROGRESSLINK %>");
       // state 0 is nothing selected
       if (state == 0) {
         changepw.style.color = "<%= activeLink %>";
         refresh.style.color = "<%= activeLink %>";
         logout.style.color = "<%= activeLink %>";
         printitem.style.color = "<%= inactiveLink %>";
         if (<%= classnum %> == -2 || <%= classnum %> == -1) {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= inactiveLink %>";
         }
         else {
           newmail.style.color = "<%= activeLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= activeLink %>";
         }
       }
       // state 1 is mail selected
       else if (state == 1) {
         changepw.style.color = "<%= activeLink %>";
         refresh.style.color = "<%= activeLink %>";
         logout.style.color = "<%= activeLink %>";
         printitem.style.color = "<%= activeLink %>";
         if (<%= classnum %> == -2 || <%= classnum %> == -1) {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= inactiveLink %>";
         }
         else {
           newmail.style.color = "<%= activeLink %>";
           replymail.style.color = "<%= activeLink %>";
           deletemail.style.color = "<%= activeLink %>";
           progress.style.color = "<%= activeLink %>";
     }
       }
       // state 2 is creating new mail
       else if (state == 2) {
         changepw.style.color = "<%= activeLink %>";
         refresh.style.color = "<%= activeLink %>";
         logout.style.color = "<%= activeLink %>";
         printitem.style.color = "<%= inactiveLink %>";
         if (<%= classnum %> == -2 || <%= classnum %> == -1) {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= inactiveLink %>";
         }
         else {
           newmail.style.color = "<%= activeLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= activeLink %>";
     }
       }
       // state 3 is replying
       else if (state == 3) {
         changepw.style.color = "<%= activeLink %>";
         refresh.style.color = "<%= activeLink %>";
         logout.style.color = "<%= activeLink %>";
         printitem.style.color = "<%= inactiveLink %>";
         if (<%= classnum %> == -2 || <%= classnum %> == -1) {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= inactiveLink %>";
         }
         else {
           newmail.style.color = "<%= activeLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= activeLink %>";
     }
       }
       // state 4 is hw selected
       else if (state == 4) {
         changepw.style.color = "<%= activeLink %>";
         refresh.style.color = "<%= activeLink %>";
         logout.style.color = "<%= activeLink %>";
         printitem.style.color = "<%= activeLink %>";
         if (<%= classnum %> == -2 || <%= classnum %> == -1) {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= inactiveLink %>";
         }
         else {
           newmail.style.color = "<%= activeLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= activeLink %>";
     }
       }
       // state 5 is creating new hw
       else if (state == 5) {
         changepw.style.color = "<%= activeLink %>";
         refresh.style.color = "<%= activeLink %>";
         logout.style.color = "<%= activeLink %>";
         printitem.style.color = "<%= inactiveLink %>";
         if (<%= classnum %> == -2 || <%= classnum %> == -1) {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= inactiveLink %>";
         }
         else {
           newmail.style.color = "<%= activeLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= activeLink %>";
     }
       }
       // state 6 is entering grades for hw
       else if (state == 6) {
         changepw.style.color = "<%= activeLink %>";
         refresh.style.color = "<%= activeLink %>";
         logout.style.color = "<%= activeLink %>";
         printitem.style.color = "<%= inactiveLink %>";
         if (<%= classnum %> == -2 || <%= classnum %> == -1) {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= inactiveLink %>";
         }
         else {
           newmail.style.color = "<%= activeLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= activeLink %>";
     }
       }
       // a special item is selected
       else if (state == 7) {
         changepw.style.color = "<%= activeLink %>";
         refresh.style.color = "<%= activeLink %>";
         logout.style.color = "<%= activeLink %>";
         printitem.style.color = "<%= activeLink %>";
         if (<%= classnum %> == -2 || <%= classnum %> == -1) {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= inactiveLink %>";
         }
         else {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= activeLink %>";
     }
       }
    }


    </SCRIPT>
  </HEAD>
  <BODY onLoad="init();setTableWidth();" onResize()="setTableWidth();">
    <FORM NAME="classinfoform" METHOD="POST">
      <INPUT TYPE="HIDDEN" NAME="<%= FormFields.CURRENT %>" VALUE="<%= FormFields.CLASSINFO %>">
      <INPUT TYPE="HIDDEN" NAME="<%= FormFields.TOKEN %>" VALUE="<%= requestObject%>">
      <INPUT TYPE="HIDDEN" NAME="<%= FormFields.PARAMETER %>" VALUE="">
      <INPUT TYPE="HIDDEN" NAME="<%= FormFields.LINKCLICKED %>" VALUE="">
      <INPUT TYPE="HIDDEN" NAME="<%= FormFields.CLASSNUM %>" VALUE="<%= classnum %>">
      <INPUT TYPE="HIDDEN" NAME="<%= FormFields.SCHOOLNAME %>" VALUE="<%= schoolName %>">
      <INPUT TYPE="HIDDEN" NAME="<%= FormFields.USRTYPE %>" VALUE="<%= loginType %>">
    </FORM>
    <SPAN STYLE="font-size:11;position:absolute; top:0px; left:0;background-color: <%=backgroundColor%>;width:100%;">
    <LEFT>
       <%
       out.print("<a STYLE=\"color:"+headingColor+";font-size:13;position:absolute; top:0px;left:0;background-color:"+ backgroundColor+"; font-family:times roman;\">&gt;&gt;<I>my</I>ClassList&nbsp&nbsp</a><HR>");
       %>
    </LEFT>
    <CENTER>
      <%
        if (classnum == -2 || classnum == -1) { // TODO Change -2 to some static constant
             out.print("<a STYLE=\"position:relative;padding-left:5;padding-right:5;font-weight:bold;vertical-align:top;text-decoration:none;color:" + inactiveMenuBar + ";font-family:"+ headingFont +";\" type=\"text\" href=\"\" onClick='return false;'>");
             out.print("Today's Updates</a>");
        }
        else {
          out.print("<a STYLE='position:relative;text-decoration:none;color:"+activeMenuBar+";font-family:"+headingFont+";' type=\"text\" href=\"\" onClick='submitPage(top.frames.mainframe.document,\"" + FormFields.CLASSINFO + "\", " + -2 + "); return false;'>");
          out.print("Today's Updates</a>");
        }
        if (classnum != -1){
	        out.print("&nbsp<B STYLE=\"color:white;\">|</B>&nbsp");
    	}
    	    
        for (int i = 0; i < classC.length-1; i++) {
           if (classnum == i){
             out.print("<a STYLE=\"padding-left:5;padding-right:5;font-weight:bold;text-decoration:none;color:" + inactiveMenuBar + ";font-family:"+headingFont+";\" type=\"text\" href=\"\" onClick='return false;'>");
             out.print(" "+ classC[i].getAssociatedCourse().getCourseShortName().toString()+" ");
           }
           else{
             out.print("<a STYLE='text-decoration:none;color:"+activeMenuBar+";font-family:"+headingFont+";' type=\"text\" href=\"\" onClick='submitPage(top.frames.mainframe.document,\"" + FormFields.CLASSINFO + "\", " + i + "); return false;'>");
             out.print(classC[i].getAssociatedCourse().getCourseShortName().toString() + " ");
           }
           out.print("</a>&nbsp<B STYLE=\"color:white;\">|</B>&nbsp");
         }

         int ii = classC.length-1;
         if (ii > -1) {
	         if (classnum == ii) {
	           out.print("<a STYLE=\"text-decoration:none;font-weight:bold;color:" + inactiveMenuBar + ";font-family:"+headingFont+";\" type=\"text\" href=\"\" onClick='return false;'>");
	           out.print(" "+ classC[ii].getAssociatedCourse().getCourseShortName().toString()+" ");
	           out.print("</a>");
	         }
	         else{
	           out.print("<a STYLE=\"text-decoration:none;color:"+activeMenuBar+";font-family:"+headingFont+";\" type=\"text\" href=\"\" onClick='submitPage(top.frames.mainframe.document,\"" + FormFields.CLASSINFO + "\", " + ii + "); return false;'>");
	           out.print(" "+ classC[ii].getAssociatedCourse().getCourseShortName().toString()+" ");
	           out.print("</a>");
	         }
		 }
      %>
    <HR>
    </CENTER>
    </SPAN>
<!-- <SPAN style="position:absolute;top:70;"> -->
<BR>&nbsp;
<DIV style="position:relative; top:10">
  <CENTER>
    <FONT STYLE="font-size:13;font-family:<%=headingFont%>;">
      <B>
        <% 
          if (classnum == -2) {
            out.println("Today's Updates");
            out.println("<BR>");
            out.println("&nbsp;");
            out.println("<BR>");
          }
          else if (classnum != -1) {
            out.println(classC[classnum].getAssociatedCourse().getCourseShortName().toString());
            out.println("<BR>");
            out.println("Instructor: " + studentClassTeacher[classnum].getFirstName().toString() + " " +  studentClassTeacher[classnum].getLastName().toString());
            out.println("<BR>");
          }
          else {
            out.println("");
          }
        %>
      </B>
      <FONT STYLE="font-size:11;">
        <B>
          <%
            if (classnum > -1) {
              out.println(classC[classnum].getClassTime().toString());
            }
            else if (classnum == -2) {
              out.println("");
            }
            else {
              out.println("NO CLASSES AVAILABLE");
            }
          %>
        </B>
      </FONT>
    </FONT>
</CENTER>
</DIV>
<DIV>
<CENTER>
  <TABLE style="position:relative;top:10;left:0;font-family:sans-serif;"id='maintable'>
    <TR>
      <TH ALIGN="LEFT">
         <DIV STYLE="font-size:11;font-family:<%=headingFont%>;width:318px"><B>Messages</B></DIV>
      </TH>
      <TH ALIGN="RIGHT">
         <DIV STYLE="font-size:11;font-family:<%=headingFont%>;width:327px"><B>Homework, Quizzes, and Tests</B></DIV>
      </TH>
    </TR>
    <TR>
      <TD ALIGN="LEFT">
              <div style="position:absolute;border-color: #000000; border-width: 1px; border-style: solid; overflow:auto; width:318; height:120">
                <div STYLE="position:absolute;top:0;left:25;clip:rect(auto 75px auto auto);font-size:10;font-family:<%=headingFont%>;"><B>From</B></div>
                <div STYLE="position:absolute;top:0;left:70;clip:rect(auto 85px auto auto);font-size:10;font-family:<%=headingFont%>;"><B>Subject</B></div>
                <div STYLE="position:absolute;top:0;left:200;clip:rect(auto 75px auto auto);font-size:10;font-family:<%=headingFont%>;"><B>Date Sent</B></div>
                <%
                if (classnum != -1) {
                  int row = 0;
                  String titleText;
                  for (int i = 0; i < commC.length; i++) {
                      titleText = studentCommTeacher[i].getLastName().toString() + "   " + commC[i].getMessage().getSubject().toString() + "   " + commC[i].getMessage().getDateTimeSent().toString();
                      out.print("<div TITLE=\"" + titleText + "\" " +
                          "STYLE=\"padding:1;position:absolute;top:"+((row+1)*1.5)+
                          "em;left:0;width:295;white-space:nowrap;\"  onClick=\"highlight(this,'Mail');switchGif(this.firstChild);"+
                          "setSelected(" + i + ");goToNextPage('" + FormFields.MAILLINK + "', getSelected());\">");
                      if (commC[i].getHidden().toString().equalsIgnoreCase("true")) {
                          out.print("<IMG name=\"imagename\" src=\"../pics/openenvelope.gif\" width=15; border=0>&nbsp;");
                      }
                      else {
                          out.print("<IMG src=\"../pics/envelope.gif\" width=15; border=0>&nbsp;");
                      }
                      out.print("<div STYLE=\"padding:1;color:blue;position:absolute;top:0;left:25;font-size:10;width:40;white-space:nowrap;overflow:hidden;clipWidth:40;\">"+
                      	  "<a href=\"\" onClick='return false;'>"+
                          DisplayString.getTruncatedString(studentCommTeacher[i].getLastName().toString(), 65, 4) + "</a></div>");
                      out.print("<div STYLE=\"padding:1;color:blue;position:absolute;left:70;top:0;font-size:10;width:120;white-space:nowrap;overflow:hidden;clipWidth:110;\"><a href=\"\" onClick='return false;'>"+
                          DisplayString.getTruncatedString(commC[i].getMessage().getSubject().toString(), 135, 4) + "</a></div>");
                      out.print("<div STYLE=\"padding:1;color:blue;position:absolute;left:200;top:0;font-size:10;width:100;white-space:nowrap;overflow:hidden;clipWidth:100;\"><a href=\"\" onClick='return false;'>"+
                          DisplayString.getTruncatedString(commC[i].getMessage().getDateTimeSent().toString(), 130, 4) + "</a></div></div>");
                      row++;
                     }
                }
                %>
              </div>
      </TD>
      <TD ALIGN="LEFT">
              <div style="position:absolute;border-color: #000000; border-width: 1px; border-style: solid; overflow:auto; width:327; height:120">
                  <div STYLE="position:absolute;top:0;left:35;clip:rect(auto 70px auto auto);font-size:10;font-family:<%=headingFont%>;"><B>Description</B></div>
                  <div STYLE="position:absolute;top:0;left:155;clip:rect(auto 85px auto auto);font-size:10;font-family:<%=headingFont%>;"><B>Assigned</B></div>
                  <div STYLE="position:absolute;top:0;left:215;clip:rect(auto 75px auto auto);font-size:10;font-family:<%=headingFont%>;"><B>Due</B></div>
                  <div STYLE="position:absolute;top:0;left:270;clip:rect(auto 40px auto auto);font-size:10;font-family:<%=headingFont%>;"><B>Score</B></div>
                  <% 
                  if (studentHomework != null) {
                    String titleText;
                    for (int i = 0; i < studentHomework.length; i++) {
                        titleText = studentHomework[i].getShortName().toString() + "   " + studentHomework[i].getDateAssigned().toString() + "   " + studentHomework[i].getDateDue().toString() + ((!studentGrade[i].getGrade().toString().equals("-1.0")) ? ("   " + studentGrade[i].getGrade().toString()) : "");
                        out.println("<div TITLE=\"" + titleText + "\" " +
                          "STYLE=\"padding:1;position:absolute;top:"+((i+1)*1.5)+"em;left:0;width:300;white-space:nowrap;\"  onClick=\"highlight(this,'HW');setSelected(" + i + ");goToNextPage('" + FormFields.HWLINK + "', getSelected());\"><IMG src=\"../pics/book.gif\" width=18;border=0>");
                        if(studentHomework[i].getAttachments().length != 0)
                            out.print("<IMG src=\"../pics/paperclip.gif\" width=15;border=0>&nbsp;");
                        out.print("<div STYLE=\"padding:1;color:blue;position:absolute;top:0em;left:35;font-size:10;width:118;white-space:nowrap;overflow:hidden;clipWidth:70;\"><a href=\"\" onClick='return false;'>"+
                          DisplayString.getTruncatedString(studentHomework[i].getShortName().toString(), 140, 4) + "</a></div>");
                        out.print("<div STYLE=\"padding:1;color:blue;position:absolute;top:0em;left:155;font-size:10;width:60;white-space:nowrap;overflow:hidden;clipWidth:60;\"><a href=\"\" onClick='return false;'>"+
                          DisplayString.getTruncatedString(studentHomework[i].getDateAssigned().toString(), 70, 4) + "</a></div>");
                        out.print("<div STYLE=\"padding:1;color:blue;position:absolute;left:215;top:0em;font-size:10;width:60;white-space:nowrap;overflow:hidden;clipWidth:60;\"><a href=\"\" onClick='return false;'>"+
                          DisplayString.getTruncatedString(studentHomework[i].getDateDue().toString(), 65, 4) + "</a></div>");
                        out.print("<div STYLE=\"padding:1;color:blue;position:absolute;left:275;top:0em;font-size:10;width:27;white-space:nowrap;overflow:hidden;clipWidth:27;\"><a href=\"\" onClick='return false;'>"+
                          DisplayString.getTruncatedString(((!studentGrade[i].getGrade().toString().equals("-1.0")) ? (studentGrade[i].getGrade().toString()) : " "), 27, 4) + ("</a></div></div>"));
                    }
                  }%>
              </div>
      </TD>
     </TR>
  </TABLE>
<CENTER>    
</DIV>
  </BODY>
</HTML>